package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLeveVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级相关接口")
public class NursingLevelController  extends BaseController {
    @Autowired
    private NursingLevelService nursingLevelService;

@GetMapping("/listAll")
    @ApiOperation("查询所有护理等级")
    public ResponseResult listAll(){
    List<NursingLeveVo> list= nursingLevelService.listAll();
    return success(list);
}
@GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult getById(@PathVariable("id") Long id){
    NursingLeveVo nursingLeveVo= nursingLevelService.getById(id);
    return success(nursingLeveVo);
}
@DeleteMapping("/delete/{id}")
    @ApiOperation("根据id删除")
public  ResponseResult deleteById(@PathVariable("id") Long id){
    nursingLevelService.deleteById(id);
    return success();
}
@PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult updateStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status){
     nursingLevelService.updateStatus(id,status);
    return success();
}
@GetMapping("/listByPage")
@ApiOperation("条件分页查询")
    public ResponseResult selectByPage(@ApiParam(value = "护理项目名称") String name, Integer status, Integer pageNum, Integer pageSize){
    PageResponse pageResponse = nursingLevelService.selectByPage(name,status,pageNum,pageSize);
    return  success(pageResponse);
}
@PostMapping("/insert")
    @ApiOperation("新增护理等级")
public ResponseResult insert(@RequestBody NursingLevelDto nursingLevelDto){
nursingLevelService.add(nursingLevelDto);
return success();
}
@PutMapping("/update")
    @ApiOperation("修改")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto){
    nursingLevelService.update(nursingLevelDto);
    return success();
}
}
